import java.util.Stack;

class MyQueue {
    Stack<Integer> s1;
    Stack<Integer> s2;

    public MyQueue() {
        s1 = new Stack<>();
        s2 = new Stack<>();
    }

    public void push(int x) {
        s1.push(x);

    }

    public int pop() {
        if (empty()) {
            return -1;
        }
        if (!s2.empty()) {
            return s2.pop();
        }
        for (int i = 0; i < s1.size(); i++) {
            int m = s1.pop();
            s2.push(m);
        }
        return s2.pop();

    }

    public int peek() {
        if (!s2.empty()) {
            return s2.peek();
        } 
            for (int i = 0; i < s1.size(); i++) {
                int m = s1.pop();
                s2.push(m);
            }
            return s2.peek();
        

    }

    public boolean empty() {
        if (s1.empty() && s2.empty()) {
            return true;
        }
        return false;
    }

}